package info.wf0913.blogger_core.service.imp;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import info.wf0913.blogger_core.bean.BaseEntity;
import info.wf0913.blogger_core.mapper.ICrudMapper;
import info.wf0913.blogger_core.service.BaseService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BaseServiceImp<T extends BaseEntity> extends ServiceImpl<ICrudMapper<T>, T> implements BaseService<T> {
    @Override
    public Page<T> listPage(int page, int limit, T entity) {
        Page<T> tPage = new Page<>();
        tPage.setCurrent(page).setSize(limit);
        baseMapper.selectPage(tPage, Wrappers.emptyWrapper());
        return tPage;
    }

    @Override
    public List<T> list(T entity) {
        return baseMapper.selectList(Wrappers.lambdaQuery(entity));
    }
}
